{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# %load E:\\Users\\ASUS\\PycharmProjects\\CV2\\SobelAndCanny.py\n",
    "import cv2 as cv\n",
    "\n",
    "filename = r'E:\\data\\lena.jpg'\n",
    "img = cv.imread(filename)\n",
    "imgGauss = cv.GaussianBlur(img,(5,5),0)  #高斯滤波\n",
    "imgGray=cv.cvtColor(img,cv.COLOR_BGR2GRAY)\n",
    "\n",
    "#Sobel算子边缘检测\n",
    "imgGraySobel=cv.Sobel(imgGray,-1,0,1,ksize=3)\n",
    "imgSobel=cv.Sobel(img,-1,0,1,ksize=3)\n",
    "cv.imshow(\"Sobel gray image \",imgGraySobel)\n",
    "cv.imshow(\"Sobel image\",imgSobel)\n",
    "\n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()\n",
    "\n",
    "#Canny算子边缘检测\n",
    "imgCanny=cv.Canny(imgGray,100,255)\n",
    "cv.imshow(\"Canny image\",imgCanny)\n",
    "\n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
